<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">

    <body>
        <ui:composition template="../templates/default3.xhtml">
            <ui:define name="content">
                <h:form id="updateRawMaterial" binding="#{productManagerBean.loadUpdateRawMaterial}">
                    <p:panel id="updateRawMaterialPanel" header="Update Raw Material">
                        <p:messages />
                        
                        <table border="0" width="100%">
                            <tr>
                                <td width="170px">Id:</td>
                                <td>
                                    <h:outputText id="code" title="Id of the raw material."
                                                 value="#{productManagerBean.rmId}">
                                    </h:outputText>
                                </td>
                            </tr>
                            <tr>
                                <td width="170px">Name:</td>
                                <td>
                                    <h:inputText id="name" label="Raw Material Name" required="true" 
                                                 requiredMessage="Raw material name cannot be empty."
                                                 title="Name of the raw material."
                                                 value="#{productManagerBean.rmName}">
                                    </h:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="170px">Shelf Life:</td>
                                <td>
                                    <h:inputText id="shelfLife" label="Shelf Life" required="true" 
                                                 requiredMessage="Shelf life cannot be empty."
                                                 title="Shelf life of the raw material."
                                                 value="#{productManagerBean.shelfLife}">
                                        <f:convertNumber type="number" />
                                    </h:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="170px">Lead Time:</td>
                                <td>
                                    <h:inputText id="leadTime" label="Lead Time" required="true" 
                                                 requiredMessage="Lead time cannot be empty."
                                                 title="Lead time of the raw material."
                                                 value="#{productManagerBean.leadTime}">
                                        <f:convertNumber type="number" />
                                    </h:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="170px">Lot Size:</td>
                                <td>
                                    <h:inputText id="lotSize" label="Lot Size" required="true" 
                                                 requiredMessage="Lot size cannot be empty."
                                                 title="Ordering lot size of the raw material."
                                                 value="#{productManagerBean.lotSize}">
                                        <f:convertNumber type="number" />
                                    </h:inputText>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="170px">Status:</td>
                                <td>
                                    <h:selectOneMenu id="selectOneStatus" value="#{productManagerBean.rmStatus}"
                                                     title="Status of the product.">
                                        <f:selectItem itemLabel="- Select Status -" itemValue="" />
                                        <f:selectItem itemLabel="Available" itemValue="Available" />
                                        <f:selectItem itemLabel="Discontinued" itemValue="Discontinued" />
                                        <f:selectItem itemLabel="Pending" itemValue="Pending" />
                                    </h:selectOneMenu>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td width="170px">Description:</td>
                                <td>
                                    <h:inputTextarea id="description" label="Description" required="true" 
                                                     requiredMessage="Description cannot be empty."
                                                     title="Description of the raw material."
                                                     style="width:450px;height:75px;" 
                                                     value="#{productManagerBean.rmDescription}">
                                    </h:inputTextarea>
                                    <font class="fieldNote">*</font>
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <p:commandButton id="btnUpdateRawMaterial" value="Update Raw Material"
                                                     ajax="true" title="Update the raw material."
                                                     update="updateRawMaterialPanel"
                                                     actionListener="#{productManagerBean.updateARawMaterial}"/>
                                    <p:commandButton id="btnRemoveRawMaterial" value="Remove Raw Material" 
                                                     onclick="confirmation.show()" type="button"
                                                     disabled="#{productManagerBean.isDiscontinued2}"
                                                     title="Remove the raw material." />
                                    <p:commandButton id="btnBackFromUpdateRawMaterial" value="Back"
                                                     immediate="true" ajax="true"
                                                     title="Go back to the previous page."
                                                     actionListener="#{productManagerBean.back}"/>
                                </td>
                            </tr>
                        </table>
                    </p:panel>
                    <p:confirmDialog  width="400" message="" header="Removing a raw material" severity="alert" widgetVar="confirmation">
                        <f:facet name="message">
                            <h:outputText value="You are going to remove a raw material."/><br/>
                            <h:outputText value="Are you sure you want to continue?"/>
                        </f:facet>    
                        <p:commandButton value="Yes" update="updateRawMaterialPanel" onclick="confirmation.hide()"
                                         actionListener="#{productManagerBean.removeRawMaterial}"/>
                        <p:commandButton value="No" update="updateRawMaterialPanel" onclick="confirmation.hide()" type="button" />
                    </p:confirmDialog>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
